package com.jusda.entity.template;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jusda.entity.level.UserScoreLevelEnum;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.Date;

/**
 * @author:y022 23/04/2022 16:38
 * @description:
 */
@Data
@Document(indexName = "user_score")
public class UserScoreTemplate {

    private Long id;
    private String name;
    @Enumerated(EnumType.STRING)
    @Field(name = "score_level")
    private UserScoreLevelEnum scoreLevel;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN",timezone = "Asia/Shanghai")
    @Field(name = "create_time",type = FieldType.Date)
    private Date createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN",timezone = "Asia/Shanghai")
    @Field(name = "update_time",type = FieldType.Date)
    private Date updateTime;

    public static UserScoreTemplate getInstance(Long id, String name, UserScoreLevelEnum scoreLevel) {
        UserScoreTemplate userScoreTemplate = new UserScoreTemplate();
        userScoreTemplate.setScoreLevel(scoreLevel);
        userScoreTemplate.setName(name);
        userScoreTemplate.setId(id);
        userScoreTemplate.setCreateTime(new Date());
        userScoreTemplate.setUpdateTime(new Date());
        return userScoreTemplate;
    }
}
